<#include "header.ftl">
<script type="text/javascript" src="${TEMPLATE_PATH}/kindeditor-4.1.7/kindeditor-min.js"></script>
<script type="text/javascript" src="${TEMPLATE_PATH}/kindeditor-4.1.7/lang/zh_CN.js"></script>
<link rel="stylesheet" href="${TEMPLATE_PATH}/themes/default/default.css" />
<script>
var editor;
KindEditor.ready(function(K) {
	editor = K.create('textarea[name="leaveMsg"]', {
		resizeType : 1,
		allowPreviewEmoticons : false,
		allowImageUpload : false,
		afterCreate : function() {
			var self = this;
			K.ctrl(document, 13, function() {
				self.sync();
			});
			K.ctrl(self.edit.doc, 13, function() {
				self.sync();
			});
		},
		afterBlur:function(){ 
	        this.sync(); 
	    },
		items : [
			'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
			'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
			'insertunorderedlist', '|', 'emoticons', 'image', 'link']
		});
});
</script>
<style>
.form-control {
	position: relative;
	margin: auto;
	font-size: 16px;
	height: 45px;padding: 9px 7px;
	width:100px;
	padding: 10px;
	-webkit-box-sizing: border-box;
   	-moz-box-sizing: border-box;
        box-sizing: border-box;
}
.rightfloat{
	float: right;
	width:170px;
}
</style>
	<#include "topbar.ftl">
    <!--container start-->
    <div class="container">
        <div class="row">
            <!--blog start-->
            <#include "sidebar.ftl">
            <div class="col-xs-9 ">
				<div class="panel panel-default">
					  <div class="panel-heading">${article.name}<div class="rightfloat">${folder.name}</div></div>
					  <div class="panel-body">            
		            	${article.content}
	                  </div>
	            </div>  
	            
	            <div class="panel panel-default">
		            <@shishuocms_article_comment_page articleId="${article.articleId?c}" p="${p}" rows="12">
		            <#if tag_article_comment_page??>
			        <#list tag_article_comment_page.list as articleComment>
				            <div class="panel-heading">
				            	${articleComment.commentIp} 
				            	<div class="rightfloat"><#if articleComment.commentTime??>${articleComment.commentTime?string("yyyy-MM-dd HH:mm:ss")}</#if></div>
				            </div>
				            <div class="panel-body">  <#if articleComment.commentContent??>${articleComment.commentContent}</#if> </div>
		            </#list>
		            <div class="text-center">
						${tag_article_comment_page.pageNumHtml}
		            </div>
		            </#if>
		            </@shishuocms_article_comment_page>
	            </div>
	            <div class="panel">
	               	<form id="add_leaveMsg_form" autocomplete="off"  method="post">
	               	  <input type="hidden" name="articleId" id="articleId" value="${article.articleId}"/>
	                  <textarea id="leaveMsg" name="leaveMsg"  style="width:100%;height:200px;visibility:hidden;" ></textarea>
	                  <div class="navbar-form">验证码：
		                  <input name="vartify_code" id="vartify_code" type="text" class="form-control" />
	                  <img id="captcha" style="cursor:pointer;cursor:hand;" onclick="this.src='${basePath}/auth/captcha.htm?'+Math.random();" src="${basePath}/auth/captcha.htm" >
		                  <button id="submit" name="submit" type="button" class="btn btn-lg btn-primary">提交</button>
	                  </div>
					</form>
	            </div>
			</div>
            <!--blog end-->
        </div>

    </div>
    <!--container end-->    

<script type="text/javascript">
$(function() {
	$("#submit").click(function(){
		if(editor.html()==""){
			bootbox.alert("评论不能为空");
			return;
		}
		var d=$("#add_leaveMsg_form").serialize();
        $.post("/article/add_leaveMsg_form.json", d, 
			function (data) 
			{ 
	        	if (data.result) {
					bootbox.alert("评论成功，将刷新页面", function() {
						window.location.reload();
					});
				}else{
					bootbox.alert("表单验证失败，请检查");
				}
			});
	});
});	
</script>
<#include "footer.ftl">